<?php
class Api_Model_GetDmban extends Zend_Db_Table_Abstract
{
	protected $_name="dmban";
	protected $_primary="Id";

	var $Id, $Ten,$IdKhuVuc, $TrangThai, $DienGiai, $NgayTao;

	public function __construct() {
		$this->_name = Zend_Registry::get('tablePrefix') . $this->_name;

		parent::__construct();
	}


	public function GetAll() {

		$query = $this->_db->select()
	    						->from(array('T1'=>'os_dmban'))
	    						->joinLeft(array('T2' => 'os_khuvuc'), 'T1.IdKhuVuc = T2.Id', array('T2.Ten as KV'));								
	    
	    $stmt = $this->_db->query($query);
	    
	   return $result = $stmt->fetchAll();
	}
	public function GetById()
	{
	    /*
	    $query = $this->_db->select()
	    					->from(array('T1'=>'os_dmban'))
	    					->joinLeft(array('T2' => 'os_luutam'), 'T1.Id = T2.IdBan', array('T2.Id as T2Id'))
	    					-> where("Ngaydatmon BETWEEN '2014-09-25 00:00:00' and '2014-09-25 23:59:59'")
	    					->where("T1.IdKhuVuc = '$this->Id'")
	    					-> group('T1.Id');
	     
	    $stmt = $this->_db->query($query);
	     
	    return $result = $stmt->fetchAll();
	    */
	    
		return $this->fetchAll("IdKhuVuc='$this->Id'")->toArray();
	}
}